package com.example.fm;

import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.Select;

import com.example.tests.ContactData;


public class ContactHelper extends HelperBase {

	public ContactHelper(ApplicationManager manager) {
		super(manager);
		
	}

	public void fillContactForm(ContactData contactInformation) {
		driver.findElement(By.name("firstname")).clear();
	   driver.findElement(By.name("firstname")).sendKeys(contactInformation.firstnameObj);
	   driver.findElement(By.name("lastname")).clear();
	   driver.findElement(By.name("lastname")).sendKeys(contactInformation.lastname);
	   driver.findElement(By.name("address")).clear();
	   driver.findElement(By.name("address")).sendKeys(contactInformation.address);
	   driver.findElement(By.name("home")).clear();
	   driver.findElement(By.name("home")).sendKeys(contactInformation.home);
	   driver.findElement(By.name("mobile")).clear();
	   driver.findElement(By.name("mobile")).sendKeys(contactInformation.mobile);
	   driver.findElement(By.name("work")).clear();
	   driver.findElement(By.name("work")).sendKeys(contactInformation.work);
	   driver.findElement(By.name("email")).clear();
	   driver.findElement(By.name("email")).sendKeys(contactInformation.email);
	   driver.findElement(By.name("email2")).clear();
	   driver.findElement(By.name("email2")).sendKeys(contactInformation.email2);
	   driver.findElement(By.name("address2")).clear();
	   driver.findElement(By.name("address2")).sendKeys(contactInformation.address2);
	   driver.findElement(By.name("phone2")).clear();
	   driver.findElement(By.name("phone2")).sendKeys(contactInformation.phone2);
	    new Select(driver.findElement(By.name("bday"))).selectByVisibleText(contactInformation.bday);
	    new Select(driver.findElement(By.name("bmonth"))).selectByVisibleText(contactInformation.bmonth);
	    driver.findElement(By.name("byear")).clear();
	    driver.findElement(By.name("byear")).sendKeys(contactInformation.byear);
	    new Select(driver.findElement(By.name("new_group"))).selectByVisibleText(contactInformation.new_group);
	    	    	    
	}

	public void submitContactCreation() {
		driver.findElement(By.name("submit")).click();
	}

	public void returnToHomePage() {
		driver.findElement(By.linkText("home page")).click();
	}

}
